//
//  MyFindWinFooterView.m
//  CarTown
//
//  Created by xionghao on 15/8/29.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "MyFindWinFooterView.h"
#import "HYSegmentedControl.h"
#import "MyWinFootViewTableViewCell.h"
#import "FooterViewTitleTableViewCell.h"
#import "FooterTitleView.h"

@interface MyFindWinFooterView ()<UITableViewDataSource,UITableViewDelegate,HYSegmentedControlDelegate>
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) HYSegmentedControl *segment;
@end


@implementation MyFindWinFooterView
-(instancetype)init{
    if (self=[super init]) {
        _segment=[[HYSegmentedControl alloc]initWithOriginY:0 Titles:@[@"按时间排序",@"价格从高到底排序"] delegate:self];
        [self addSubview:_segment];
        
        _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 80, XHScreenwidth, 240) style:UITableViewStylePlain];
        _tableView.delegate=self;
        _tableView.dataSource=self;
        _tableView.rowHeight=60;
        UINib *nib=[UINib nibWithNibName:NSStringFromClass([MyWinFootViewTableViewCell class]) bundle:nil];
        [_tableView registerNib:nib forCellReuseIdentifier:@"myfooter"];
        FooterTitleView *title=[FooterTitleView title];
       
        [self addSubview:title];
        self.frame=CGRectMake(0, 0, XHScreenwidth, 310);
        if ([_tableView respondsToSelector:@selector(setSeparatorInset:)]) {
            
            [_tableView setSeparatorInset:UIEdgeInsetsZero];
            
        }
        
        if ([_tableView  respondsToSelector:@selector(setLayoutMargins:)]) {
            
            [_tableView setLayoutMargins:UIEdgeInsetsZero];
            
        }
        [self addSubview: _tableView];
    }
    return self;
}

-(void)hySegmentedControlSelectAtIndex:(NSInteger)index{
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([_delegate respondsToSelector:@selector(tableViewClick:)]) {
        [_delegate tableViewClick:indexPath.row];
    }
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        
        [cell setSeparatorInset:UIEdgeInsetsZero];
        
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        
        [cell setLayoutMargins:UIEdgeInsetsZero];
        
    }
    
    
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
 
        MyWinFootViewTableViewCell *cell=[MyWinFootViewTableViewCell cellWithTableView:tableView];
        return cell;
   
    
}

@end
